package com.phonemica.utils;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class AsyncHttpUtils {
	private static final String TAG = AsyncHttpUtils.class.getSimpleName();
	private static AsyncHttpUtils instance;
	private static AsyncHttpClient mAsyncHttpClient;

	private AsyncHttpUtils() {
		mAsyncHttpClient = new AsyncHttpClient();
		mAsyncHttpClient.setTimeout(3000);
	}

	public synchronized static AsyncHttpUtils getIntance() {
		if (null == instance) {
			instance = new AsyncHttpUtils();
		}
		return instance;
	}

	public void get(String url, RequestParams requestParams,
			AsyncHttpResponseHandler responseHandler) {
		mLog.d(TAG, "get : " + url);
		mAsyncHttpClient.get(url, requestParams, responseHandler);
	}

	public void get(String url, AsyncHttpResponseHandler responseHandler) {
		mLog.d(TAG, "get : " + url);
		mAsyncHttpClient.get(url, responseHandler);
	}

	public void post(String url, RequestParams requestParams,
			AsyncHttpResponseHandler responseHandler) {
		mLog.d(TAG, "post : " + url);
		mAsyncHttpClient.post(url, requestParams, responseHandler);
	}
}
